# -*- coding: utf-8 -*-
#Created on Sat Sep 1 16:54:15 2018
#@author: JockJo

import mongo_util

def normalize(name):
    return name[0].upper() + name[1:].lower()

m = mongo_util.Mongo()
item = {}
f = open(r'C:\Users\JockJo\Desktop\公司文件163651013\TRD_Co.txt',encoding='utf-8')
lines = f.readlines()
lines = lines[1:]
for line in lines:
    line = line.split('\t')
    item['Stkcd'] = line[0]
    item['Stknme'] = line[1]
    item['Conme'] = line[2]
    item['Conme_en'] = normalize(line[3])
    item['Estbdt'] = line[4]
    item['Listdt'] = line[5]
    item['Markettype'] = line[6][0:-1]
    #print(item)
    m.process_item(item,collection_name='company')
